home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / Screens / ColourBars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-09  |  3.6 KB  |  99 lines

  1. /*
  2. ** Name:      Colourlist Example
  3. ** Author:    Adam Dawes and Paul Manias
  4. ** Copyright: DreamWorld Productions (c) 1996.  Freely Distributable.
  5. ** SAS/C:     1> sc ColourBars.c link startup=LIB:gms.o data=far nostackcheck
  6. **  Dice:     1> dcc -l0 -mD gms.o ColourBars.c -o ColourBars
  7. **
  8. ** Colourlists are those nice colour gradients used in demos and games,
  9. ** usually  sitting in the background of your screen.  Colourlists are mostly
  10. ** good for getting more colours on screen than what is really available.
  11. ** Although  GMS allows you to do other screen effects based on raster lines,
  12. ** we'll just stick to changing colours in this demo.
  13. ** 
  14. ** You can move the green colour bar by moving the mouse up and down.
  15. ** You will notice that if you move the green bar into the upper red bar,
  16. ** your bar will disappear and leave some green lines at the end of the red
  17. ** bar.  This is because:
  18. ** 
  19. **   WAITLINE  95        ;Wait for line 95
  20. **   WAITLINE 100        ;Wait for line 100
  21. **   WAITLINE  90        ;Wait for line 90 <--Error! 
  22. ** 
  23. ** Is illegal.  The monitor beam travels down the screen, and so the
  24. ** UpdateRasterlist() routine will expect all lines to be in sequential order.
  25. ** Moving two colourbars into each other breaks this rule, causing the wait
  26. ** command to be ignored.  If you want to get around this (green bar appears
  27. ** on top of red bar), you will have to have just one large colourlist and
  28. ** sort your colours before each call to UpdateRasterlist().
  29. ** 
  30. ** Similarly if you move the colour bar too far down the screen the hardware
  31. ** won't like it because lines > 311 don't exist.  It's up to you to be
  32. ** responsible enough to stop this from happening!
  33. ** 
  34. ** Press the left mouse button to exit the demo.
  35. */
  36.  
  37. #include <proto/games.h>
  38.  
  39. extern struct GMSBase *GMSBase;
  40. APTR   PREFSNAME = DEFAULT;
  41.  
  42. LONG ColourBar1[] = {
  43.      0x100000,0x200000,0x300000,0x400000,0x500000,0x600000,0x700000,0x800000,0x900000,0xa00000,
  44.      0xb00000,0xc00000,0xd00000,0xe00000,0xe00000,0xe00000,0xd00000,0xc00000,0xb00000,0xa00000,
  45.      0x900000,0x800000,0x700000,0x600000,0x500000,0x400000,0x300000,0x200000,0x100000,0x000000,
  46.      -1
  47. };
  48.  
  49. LONG ColourBar2[] = {
  50.      0x001000,0x002000,0x003000,0x004000,0x005000,0x006000,0x007000,0x008000,0x009000,0x00a000,
  51.      0x00b000,0x00c000,0x00d000,0x00e000,0x00f000,0x00e000,0x00d000,0x00c000,0x00b000,0x00a000,
  52.      0x009000,0x008000,0x007000,0x006000,0x005000,0x004000,0x003000,0x002000,0x001000,0x000000,
  53.      -1
  54. };
  55.  
  56. LONG ColourBar3[] = {
  57.      0x000010,0x000020,0x000030,0x000040,0x000050,0x000060,0x000070,0x000080,0x000090,0x0000a0,
  58.      0x0000b0,0x0000c0,0x0000d0,0x0000e0,0x0000f0,0x0000e0,0x0000d0,0x0000c0,0x0000b0,0x0000a0,
  59.      0x000090,0x000080,0x000070,0x000060,0x000050,0x000040,0x000030,0x000020,0x000010,0x000000,
  60.      -1
  61. };
  62.  
  63. ULONG Rasterlist[] = {
  64.      COLOURLIST(000,3,00,&ColourBar1),   /* Line, Skip, Colnum, ColourList */
  65.      COLOURLIST(160,1,00,&ColourBar2),   /* Line, Skip, Colnum, ColourList */
  66.      COLOURLIST(230,1,00,&ColourBar3),   /* Line, Skip, Colnum, ColourList */
  67.      RASTEND
  68. };
  69.  
  70. void main(void)
  71. {
  72.    struct GameScreen *GameScreen;
  73.    WORD   barpos = 160;
  74.    ULONG  mouse;
  75.  
  76.    if (GameScreen = AddScreenTags(TAGS_GAMESCREEN,NULL,
  77.        GSA_Rasterlist,&Rasterlist,
  78.        GSA_Planes,1,
  79.        GSA_Attrib,BLKBDR,
  80.        TAGEND)) {
  81.  
  82.       ShowScreen(GameScreen);
  83.       InitJoyPorts();
  84.  
  85.       do {
  86.          mouse = ReadJoyPort(JPORT1,JT_ZBXY);
  87.          barpos += (BYTE)mouse;
  88.          if (barpos < 0) barpos = 0;
  89.          if (barpos > 226) barpos = 226;
  90.          Rasterlist[4] = (Rasterlist[4] & 0xffff0000)|barpos;
  91.          UpdateRasterLines(GameScreen);
  92.          WaitVBL();
  93.       } while (!(mouse & MB_LMB));
  94.  
  95.    DeleteScreen(GameScreen);
  96.    }
  97. }
  98.  
  99.